package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.BatchFlowBillEntity;
import com.xbongbong.saas.domain.entity.BatchFlowBillEntityExt;
import com.xbongbong.saas.domain.entity.BatchFlowBillUpdateEntity;
import com.xbongbong.saas.domain.entity.StockFlowBillEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 流水记录表
 * @author lee
 * @date 2020/1/13 16:51
 * @since v1.0
 * @version v1.0
 */
@Repository
@Mapper
public interface BatchFlowBillDao {
    /**
     * 插入数据
     *
     * @param batchFlowBillEntity 表单实体数据
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    Integer insert(BatchFlowBillEntity batchFlowBillEntity);
    /**
     * 更新数据
     *
     * @param batchFlowBillEntity 表单实体数据
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    Integer update(BatchFlowBillEntity batchFlowBillEntity);
    /**
     * 删除单条数据
     *
     * @param key 主键
     * @param corpid 公司ID
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);
    /**
     * 根据索引查询数据
     *
     * @param key 主键
     * @param corpid 公司ID
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    BatchFlowBillEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);
    /**
     * 根据索引查询数据
     *
     * @param param 查询参数
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    List<BatchFlowBillEntity> findEntitys(@Param("param") Map<String, Object> param);
    /**
     * 获取数据条数
     *
     * @param param 查询参数
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     **/
    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    Integer insertBatch(@Param("list") List<BatchFlowBillEntity> stockFlowBillList);

    Integer updateBatch(@Param("list") Collection<BatchFlowBillUpdateEntity> updateList, @Param("corpid") String corpid, @Param("warehouseKeyList") Set<String> warehouseKey);

    Integer updateGreaterThanTime(@Param("list") Collection<BatchFlowBillUpdateEntity> updateList, @Param("corpid") String corpid, @Param("batchKeyList") Set<String> b);

    List<BatchFlowBillEntity> getLatestFlowBillByWarehouseKey(@Param("param") Map<String, Object> param);

    Integer deleteByRefIdIn(@Param("corpid") String corpid, @Param("refIdIn") List<Long> refIdIn, @Param("businessTypeIn") List<Integer> businessTypeIn);

    List<BatchFlowBillEntityExt> getFlowInfo(@Param("param") Map<String, Object> param);

    Integer getGroupByEntitysCount(@Param("param") Map<String, Object> param);

    List<String> getLatestDistinctBatch(@Param("corpid")String corpid, @Param("batchLike") String batchLike);

    void deleteAllByCorpId(@Param("corpid")String corpid);

    void updateBatchByParentId(@Param("corpid")String corpid, @Param("parentId")Long parentId, @Param("visible")Integer visible);

    List<BatchFlowBillEntity> queryBatchFlowbydate(@Param("param")Map<String, Object> param);

    void updateBatchFlowById(@Param("list")List<BatchFlowBillEntity> batchFlowBillEntityList, @Param("corpid")String corpid);

    List<BatchFlowBillEntity> queryBatchFlowbydateAndId(@Param("corpid")String corpid, @Param("data")Long date, @Param("list")List<Long> productId);

    void deleteByAddTime(@Param("param") Map<String, Object> param);

    List<BatchFlowBillEntity> getBatchFlowByBatchKey(@Param("corpid")String corpid, @Param("list")List<String> batchKeyList);

    BatchFlowBillEntity getBatchFlowBillBytime(@Param("corpid")String corpid, @Param("productId")Long productId, @Param("warehouseId")Long warehouseId, @Param("batchKey")String batchKey);
}
